package com.rj.bd.admin.controller;

import java.util.List;
import java.util.Map;

import javax.xml.ws.ResponseWrapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.rj.bd.admin.entity.Admin;
import com.rj.bd.admin.service.IAdminService;
import com.rj.bd.user.entity.User;


@ResponseBody
@Controller
@RequestMapping("/admin")
public class AdminConrtoller {
	@Autowired
	private IAdminService adminService;
	/**
	 * @desc 管理员登录
	 * @param name
	 * @param password
	 * @return
	 */
	@RequestMapping("/login")
	public Map<String, Object> login(String name,String password)
	{
		System.out.println("admin-------->login");
		Map<String, Object> map=adminService.login(name, password);
		return map;
	}
	 /**
	  * @desc 管理员查询所有用户
	  * @return
	  */
	@RequestMapping("/queryUser")
	public Map<String, Object> queryUser(){
		System.out.println("admin--------->queryUser");
		Map<String, Object> map=adminService.queryUser();
		return map;
	}
	
	/**
	 * @desc 管理员查询Shop
	 * @return
	 */
	@RequestMapping("/queryShop")
	public Map<String, Object> queryShop(){
		System.out.println("admin--------->queryshop");
		Map<String, Object> map=adminService.queryShop();
		return map;
	}
	/**
	 * @desc 查询Coversion
	 * @return
	 */
	@RequestMapping("/queryCoversion")
	public Map<String, Object> queryCoversion(){
		System.out.println("admin--------->Coversion");
		Map<String, Object> map=adminService.queryConversion();
		return map;
	}
	/**
	 * @desc 添加用户
	 */
	@RequestMapping("/addUser")
	public Map<String, Object> addUser(String username,String password,String name,String sex,String tel,String money){
		System.out.println("admin---------->addUser");
		Map<String, Object> map=adminService.addUser(username,password,name,sex,tel,money);
		return map;
	}
	/**
	 * @desc 管理员查询商品记录
	 */
	@RequestMapping("/queryShopJilu")
	public Map<String, Object> queryShopJilu(){
		System.out.println("admin---------->queryShopJilu");
		Map<String, Object> map=adminService.queryShopJilu();
		return map;
	}
	/*
	 * @desc 管理员修改用户积分
	 */
	@RequestMapping("/updateUserMoney")
	public Map<String, Object> updateUserMoney(String money,String userId){
		System.out.println("admin---------->updateUserMoney");
		Map<String, Object> map=adminService.updateUserMoney(money, userId);
		return map;
	}
}
